GrapeCity MultiRow Windows Forms Documentation
Sort(SortItem[]) Method
Example 


A SortItem array.
Sorts the contents of the GcMultiRow control according to the SortItems.
Syntax
<FeatureAttribute(Name="Sort", Version="v5.0")>
Public Overloads Sub Sort( _
   ByVal sortItems() As SortItem _
) 
Dim instance As GcMultiRow
Dim sortItems() As SortItem
 
instance.Sort(sortItems)
[Feature(Name="Sort", Version="v5.0")]
public void Sort( 
   SortItem[] sortItems
)

Parameters

sortItems
A SortItem array.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionThe sortItems parameter is a null reference (Nothing in Visual Basic).
System.ArgumentExceptionThe sortItems array has no items.
System.InvalidOperationException

This method cannot be accessed when the Template is a null reference (Nothing in Visual Basic).

-or-

VirtualMode is true and DataSource is a null reference (Nothing in Visual Basic).

Remarks

This method can sort multiple columns at the same time by using multiple SortItems.

This method allows advanced customization of the sorting feature in the GcMultiRow class. In order to implement a highly customized sorting operation, write an event handler for the CellMouseClick event for ColumnHeaderCell and call this method with an instance of a class that implements the System.Collections.IComparer interface as a member of SortItem. In this case, you typically set the SortMode property to SortMode.Programmatic to disable automatic sorting and to leave room for a sorting glyph. When sorting by cells set to programmatic sort mode, you must display the sorting glyph yourself by setting the SortGlyphDirection property.

If the AllowUserToAddRows property value is true, the last row is always the last row. In this case, the sorting operator does not effect the last row (uncommitted new row).

Example
The following code example shows how to sort multiple cells. To run this example, create a GcMultiRow control in a form with a template. The template should contain at least two cells in the row. You can call this method in a button click event handler or form load event.
void SortByCodeMultiCells()
        {
            SortItem sortItem1 = new SortItem(0, SortOrder.Ascending);
            SortItem sortItem2 = new SortItem(1, SortOrder.Descending);

            SortItem[] sortItems = new SortItem[] { sortItem1, sortItem2 };

            // In one sort operator, sort two cells in all rows by using SortItem.
            this.gcMultiRow1.Sort(sortItems);
        }
Private Sub SortByCodeMultiCells()
        Dim sortItem1 As New SortItem(0, SortOrder.Ascending)
        Dim sortItem2 As New SortItem(1, SortOrder.Descending)

        Dim sortItems As SortItem() = New SortItem() {sortItem1, sortItem2}

        ' In one sort operator, sort two cells in all rows by using SortItem.
        Me.gcMultiRow1.Sort(sortItems)
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GcMultiRow Class
GcMultiRow Members
Overload List
SortItem Class

 

 


Copyright © GrapeCity, inc. All rights reserved.